﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TreasureBox : MonoBehaviour
{

    public GameObject treasureDialog, dashImage, shadowPool;
    private Animator anim;

    void Start()
    {
        anim = GetComponent<Animator>();
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E) && treasureDialog.activeInHierarchy)
        {
            anim.SetTrigger("open");
            dashImage.SetActive(true);
            shadowPool.SetActive(true);
        }
    }

    private void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.tag == "Player")
        {
            treasureDialog.SetActive(true);

        }
    }

    private void OnTriggerExit2D()
    {
        treasureDialog.SetActive(false);
    }

    public void Death()
    {
        Destroy(gameObject);
    }

}
